<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="css/eui.css">
    <style>
        .el-dropdown-link {
            cursor: pointer;
            /*cursor: 光标
            pointer:指针*/
            color: #409EFF;
        }
        .el-icon-arrow-down {
            font-size: 12px;
        }
    </style>
</head>
<body>
<div id="app">
    <el-dropdown trigger="click">
        <!--可以配置 click 激活或者 hover 激活。
        在trigger属性设置为click即可。-->
  <span class="el-dropdown-link">
    下拉菜单<i class="el-icon-arrow-down el-icon--right"></i>
  </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>黄金糕</el-dropdown-item>
            <el-dropdown-item>狮子头</el-dropdown-item>
            <el-dropdown-item>螺蛳粉</el-dropdown-item>
            <el-dropdown-item disabled>双皮奶</el-dropdown-item>
            <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
            <!--divided: 分割-->
        </el-dropdown-menu>
    </el-dropdown>

   <!-- <el-dropdown @command="handleCommand">
  <span class="el-dropdown-link" >
    选择你的三国英雄<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>
  </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-for="name in arr" :command="name">{{name}}</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>-->
    <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            选择你的英雄<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item v-for="name in arr" :command="name">{{name}}</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
    <!--divided: 分割         name 属于变量,需要加属性绑定-->
    <p>{{info}}</p>
    <hr>
    <h1>可使用按钮触发下拉菜单</h1>
    <el-dropdown>
        <el-button type="primary">
            更多菜单<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>黄金糕</el-dropdown-item>
            <el-dropdown-item>狮子头</el-dropdown-item>
            <el-dropdown-item>螺蛳粉</el-dropdown-item>
            <el-dropdown-item>双皮奶</el-dropdown-item>
            <el-dropdown-item>蚵仔煎</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
    <el-dropdown split-button="true" type="primary" @click="handleClick">
        更多菜单<!--设置split-button属性来让触发下拉元素呈现为按钮组，
        左边是功能按钮，右边是触发下拉菜单的按钮，设置为true即可。-->
        <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>黄金糕</el-dropdown-item>
            <el-dropdown-item>狮子头</el-dropdown-item>
            <el-dropdown-item>螺蛳粉</el-dropdown-item>
            <el-dropdown-item disabled>双皮奶</el-dropdown-item>
            <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
        </el-dropdown-menu>
    </el-dropdown>
    <h1 v-text="message"></h1>
    <hr>
    <input type="text" v-model="hero">
    <input type="button" value="添加" @click="add()">
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script>
    let v=new Vue({
        el: '#app',
        data: function() {
            return {
                arr:["刘备","关羽","张飞",
                "赵云","曹操"],
                info:"",
                message:"",
                hero:"",
            }
        },
        methods:{
            //方法名 参数名可改,事件名不可改
            handleCommand(command){
                //把传递过来的值 弹出
                v.$message.success(command);
                v.info=command
            },
            handleClick(){
                alert("button click");
                v.message+="button click!!!!"
            },
            add(){
                if (v.hero==""){
                    return
                }
                v.arr.push(v.hero);
                v.hero="";
            }
        }
    })
</script>
</html>